import React, {
    Component,
} from 'react';

import {
    Text,
    View,
    Image,
    TouchableWithoutFeedback,
} from 'react-native';

import styles from "./css/fillInfo";

import {fill_info} from '../../actions/reglogin';

export default class FillInfo extends Component {

    constructor(props){
        super(props);
        let appface = this.props.navigation.getParam('appface', "");
        let nickname = this.props.navigation.getParam('nickname', "");
        let birthday = this.props.navigation.getParam('birthday', "");
        this.state = {
            appface: appface,
            nickname: nickname,
            birthday: birthday
        }
    }

    //微信填写信息
    _wxFillInfo(sex){
        fill_info(this, this.state.nickname, sex, this.state.birthday);
    }

    render() {
        if(this.state.appface != "" && this.state.nickname != "" && this.state.birthday != ""){
            return this._renderQuickReg();
        }else{
            return this._renderFillInfo();
        }
    }

    _renderQuickReg(){
        return (
            <View style={styles.container}>
                <Text style={styles.font}>为给你提供更好服务</Text>
                <Text style={styles.font}>请选择性别</Text>
                <View style={styles.sexGroup}>
                    <TouchableWithoutFeedback
                        onPress={() => this._wxFillInfo(1)}>
                        <Image
                            style={styles.icon}
                            source={require('./img/boy_icon.png')}
                            />
                    </TouchableWithoutFeedback>
                    <TouchableWithoutFeedback
                        onPress={() => this._wxFillInfo(2)}>
                        <Image
                            style={styles.icon}
                            source={require('./img/girl_icon.png')}
                            />
                    </TouchableWithoutFeedback>
                </View>
                <Text style={styles.warm}>性别选择后不可修改，请慎重</Text>
            </View>
        )
    }

    _renderFillInfo(){
        return (
            <View>
                <Text>
                    填写个人资料
                </Text>
                <Image
                    style={{width: 50, height: 50}}
                    source={{uri: this.state.appface}}
                    />
            </View>
        )
    }
}